#!/usr/bin/env python3
# _*_coding:utf-8 _*_
__author__ = "Gao"
from django import template
from django.utils.safestring import mark_safe

register = template.Library()

@register.simple_tag
def article_type_all(args):
    '''全选'''
    res_str = ''
    if not args.get('article_type'):
        res_str = '<li class="active"><a  href="/">全部</a></li>'
    else:
        res_str = '<li><a href="/">全部</a></li>'

    return mark_safe(res_str)


@register.simple_tag
def article_type_one(article_types,args):
    '''选择单一项'''
    res_str = []
    for row in article_types:
        if str(row[0]) == args.get('article_type'):

            temp = '<li class="active"><a class="active" href="/all/%s.html">%s</a></li>'%(row[0],row[1])
        else:
            temp = '<li><a href="/all/%s.html">%s</a></li>'%(row[0],row[1])
        res_str.append(temp)
    return mark_safe(''.join(res_str))